package com.agan.jvm.test07.lesson09;

import java.util.ArrayList;
import java.util.List;
/**
 * @author 阿甘
 * @see https://study.163.com/course/introduction/1211562809.htm?share=1&shareId=1028852228
 * @version 1.0
 * 注：如有任何疑问,欢迎加阿甘老师微信agan-java 进行讨论
 */
public class Singleton {
    private static Singleton instance;

    private List list;

    public List getList() {
        return list;
    }

    public void setList(List list) {
        this.list = list;
    }

    private Singleton (){}

    public static synchronized Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }

    public static void main(String[] args) {
        List list= new ArrayList();
        for (int i = 1; i<10; i++)
        {
            Object o = new Object();
            list.add(o);
        }
        Singleton.getInstance().setList(list);
    }

}

